find the smallest divisor given a threshold gfg